home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Demos / Component Software / FileFlex 2.0.3.sit / FileFlex 2.0.3 / Unsupported & Undocumented / Char Translation Example / 00002_Script_2 < prev    next >
Text File  |  1996-04-10  |  1KB  |  43 lines

  1. on buildTranslateTable_ASCIIX
  2.   global ASCIIX
  3.   put "" into theTable
  4.   repeat with i = 0 to 255
  5.     if i = 0 then
  6.       put numToChar(255) after theTable -- always use 255 in byte 0
  7.     else
  8.       put numToChar(i) after theTable -- position in table
  9.     end if
  10.   end repeat
  11.   put theTable into ASCIIX
  12. end buildTranslateTable_ASCIIX
  13.  
  14. on buildTranslateTable_CaseReverseX
  15.   global CaseReverseX, ASCIIX
  16.   buildTranslateTable_ASCIIX
  17.   put ASCIIX into theTable
  18.   -- fill in lower case
  19.   repeat with i = 65 to 90
  20.     put numToChar(i+32) into char i+1 of theTable 
  21.     -- using i+1 above because strings begin at 1, not 0
  22.   end repeat
  23.   -- fill in upper case
  24.   repeat with i = 97 to 122
  25.     put numToChar(i-32) into char i+1 of theTable 
  26.   end repeat
  27.   put theTable into CaseReverseX
  28. end buildTranslateTable_CaseReverseX
  29.  
  30. on showTable theTable
  31.   repeat with i = 1 to 256
  32.     put padNum(i-1) & ": " into tableRecord
  33.     put padNum(charToNum(char i of theTable)) after tableRecord
  34.     put " " & char i of theTable after tableRecord
  35.     put tableRecord
  36.   end repeat
  37. end showTable
  38.  
  39. on padNum num
  40.   if num < 10 then return "00" & string(num)
  41.   if num < 100 then return "0" & string(num)
  42.   return string(num)
  43. end padNum